//
//  KSProgressItem.swift
//  Slaughter
//
//  Created by 邱仙凯 on 2022/9/19.
//  Copyright © 2025 aowang. All rights reserved.
//

import UIKit
 
class KSProgressItem: KSFormHItem {
    // MARK: - 懒加载 lazy
     lazy var bgv:UIView = {
        let v = UIView()
         v.layer.masksToBounds = true
         v.layer.cornerRadius = 3
         v.backgroundColor = UIColor(kshex: "f7f7f7")
        return v
    }()
    lazy var red:UIView = {
       let v = UIView()
         v.backgroundColor = UIColor(kshex: "FF4500")
        v.isHidden = true
       return v
   }()
    lazy var yellow:UIView = {
       let v = UIView()
     
        v.backgroundColor = UIColor(kshex: "FFA500")
        v.isHidden = true
       return v
   }()
    lazy var green:UIView = {
       let v = UIView()
      
        v.backgroundColor = UIColor(kshex: "228B22")
        v.isHidden = true
       return v
   }()
 
    convenience init(title:String,appearance: KSFormBaseAppear? = KSFormBaseAppear()) {
        self.init(title: title, appearance: appearance,type:.progress)
        
        self.addSubview(bgv)
        bgv.snp.makeConstraints { make in
            make.left.equalTo(self.tpTitleLab.snp.right).offset(20)
             make.height.equalTo(7)
            make.right.equalTo(self).offset(-self.appearance.contentTrailing)
            make.centerY.equalTo(self)
        }
        bgv.addSubview(red)
        red.snp.makeConstraints { make in
            make.left.top.bottom.equalTo(bgv)
            make.width.equalTo(bgv.snp.width).dividedBy(3)
        }
        bgv.addSubview(yellow)
        yellow.snp.makeConstraints { make in
            make.top.bottom.equalTo(bgv)
            make.left.equalTo(red.snp.right)
            make.width.equalTo(bgv.snp.width).dividedBy(3)
        }
        bgv.addSubview(green)
        green.snp.makeConstraints { make in
            make.right.top.bottom.equalTo(bgv)
            make.width.equalTo(bgv.snp.width).dividedBy(3)
        }
      }
    
    func setpwdStrength(flag:Int) {
        switch flag {
        case 0:
            red.isHidden = true
            yellow.isHidden = true
            green.isHidden = true
        case 1:
            red.isHidden = false
            yellow.isHidden = true
            green.isHidden = true
        case 2:
            red.isHidden = false
            yellow.isHidden = false
            green.isHidden = true
        case 3:
            red.isHidden = false
            yellow.isHidden = false
            green.isHidden = false
        default:
            break
        }
    }
   
    
}
